/**
 * This file is part of Idegen, the application to create IDE project files.
 *
 * @copyright Copyright (c) 2011-2012, Walter Tamboer http://waltertamboer.nl
 * @file Idegen/IO/FileSystem.hpp
 */

#ifndef IDEGEN_IO_FILESYSTEM_HPP
#define IDEGEN_IO_FILESYSTEM_HPP

namespace Idegen
{
	class Directory;
	class File;
	
	typedef std::vector< Directory > DirectoryList;
	typedef std::vector< File > FileList;
	typedef std::vector< std::string > StringList;

	/**
	 * Converts the absolute path to a relative path.
	 *
	 * @param[in] path The absolute path to convert.
	 * @return Returns the relative path.
	 */
	std::string AbsoluteToRelativePath( const std::string& path );

	/**
	 * Converts the absolute path to a relative path.
	 *
	 * @param[in] path The absolute path to convert.
	 * @param[in] base The path to start to which we are relative.
	 * @return Returns the relative path.
	 */
	std::string AbsoluteToRelativePath( const std::string& path, const std::string& base );

	/**
	 * Appends a system slash at the end if it's not already there.
	 *
	 * @param[in] path The path to convert.
	 * @return Returns the path with the appended system slash.
	 */
	std::string AppendSystemSlash( const std::string& path );

	/**
	 * Converts all the slashes to system slashes.
	 *
	 * @param[in] path The path to convert.
	 * @return Returns the converted path.
	 */
	std::string ConvertToSystemSlashes( const std::string& path );

	/**
	 * Creates a directory located at the given path.
	 *
	 * @param[in] path The path to create.
	 */
	void CreateDirectory( const std::string& path );

	/**
	 * Checks if the file exists.
	 *
	 * @param[in] path The path of the file.
	 * @return Returns true when the file exists; false otherwise.
	 */
	bool FileExists( const std::string& path );

	/**
	 * Gets a list with all the directories in the given directory.
	 *
	 * @param[in] path The path to the directory to get the subdirectories from.
	 * @return Returns a list with all the directories.
	 */
	DirectoryList GetDirectories( const std::string& path );

	/**
	 * Gets the path of the directory for the given file.
	 *
	 * @param[in] path The path to get the directory for.
	 * @return Returns a string.
	 */
	std::string GetDirectoryPath( const std::string path );

	/**
	 * Gets a list with all the files in the given directory.
	 *
	 * @param[in] path The path to the directory to get the files from.
	 * @param[in] depth The maximum depth to go into directories.
	 * @return Returns a list with all the files.
	 */
	FileList GetFiles( const std::string& path, int depth );

	/**
	 * Gets the startup directory of the application.
	 *
	 * @return Returns the startup directory of the application.
	 */
	std::string GetStartupDirectory();

	/**
	 * Converts the relative path to an absolute path.
	 *
	 * @param[in] path The relative path to convert.
	 * @param[in] appendSlash Whether or not to append a slash to the end.
	 * @return Returns the absolute path.
	 */
	std::string RelativeToAbsolutePath( const std::string& path, bool appendSlash );

	/**
	 * Converts the relative path to an absolute path.
	 *
	 * @param[in] path The relative path to convert.
	 * @param[in] base The base path to calculate from.
	 * @param[in] appendSlash Whether or not to append a slash to the end.
	 * @return Returns the absolute path.
	 */
	std::string RelativeToAbsolutePath( const std::string& path, const std::string& base, bool appendSlash );

	/**
	 * Splits the path into a list.
	 *
	 * @param[in] path The path to split.
	 * @return Returns a list with all the path's parts.
	 */
	StringList SplitPath( const std::string& path );
}

#endif

